/**
 * FileNode.java
 * 
 * @author Lex 2007-9-12 ����12:24:38
 */
package org.lex.io.filesystem;

import java.io.File;

import org.lex.utils.tree.AbstractNode;


public class FileNode extends AbstractNode {
	private static final FileNode[] EMPTY = new FileNode[0];
	private FileNode[] children = EMPTY;

	public FileNode(File file) {
		super(file);
		File[] files = file.listFiles();
		if (null == files)
			this.children = EMPTY;
		else {
			children = new FileNode[files.length];
			for (int i = 0; i < files.length; i++)
				children[i] = new FileNode(files[i]);
		}
	}

	@Override
	public File getData() {
		return (File) super.getData();
	}

	@Override
	public FileNode getChildAt(int index) {
		return this.children[index];
	}

	@Override
	public int getChildCount() {
		return this.children.length;
	}
}
